package com.面试题;

import java.util.Stack;

public class CheckSambel {


        public static void main(String[] args) {
            boolean flag = true;
            //String target = "{[{()}]()}";
            String target = "{[{()}]()}";
            Stack<Character> stack = new Stack<Character>();
            for (Character i : target.toCharArray()){
                if (i=='(' || i=='['|| i=='{'){
                    stack.push(i);
                }else if (i==')'){
                    if (stack.size()==0||stack.pop()!='('){
                        flag = false;
                    }
                }else if (i==']'){
                    if (stack.size()==0||stack.pop()!='['){
                        flag = false;
                    }
                }else if (i=='}'){
                    if (stack.size()==0||stack.pop()!='{'){
                        flag = false;
                    }
                }
            }
            if (stack.size()!=0){
                flag = false;
            }

            System.out.println(flag);

        }


}
